import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Window 2.2
import QtQuick.Controls 2.5

Popup {
    id: notify
    property alias text: msg.text

    width: 150
    height: 40
    padding: 0
    parent: Overlay.overlay
    x: (parent.width-width)/2
    y: parent.height - height - 20
    background: Item {

    }
    Rectangle {
        radius: 20
        color: "#aaa"
        anchors.fill: parent
        id: notifyRec
        transitions: [
            Transition {
                from: "open"
                to: "close"
                OpacityAnimator {
                    target: notifyRec
                    from: 1
                    to: 0
                    duration: 1500
                }
            },Transition {
                from: "close"
                to: "open"
                OpacityAnimator {
                    //from: 0
                    to: 1
                    target: notifyRec
                    duration: 1500
                }
            }
        ]
        state: "close"
        Text {
            id: msg
            anchors.centerIn: parent
            color: "red"
            font.pixelSize: 18
        }
        Timer {
            id: timerOpen
            interval: 2500;
            onTriggered: {
                notifyRec.state = "close"
                timerClose.restart()
            }


        }
        Timer {
            id: timerClose
            interval: 1500;
            onTriggered: {
                notify.close()
            }


        }

    }

    onOpened: {
        timerOpen.restart()
        notifyRec.state = "open"
    }



}
